import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { filter, map } from 'rxjs/operators';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent implements OnInit {
  title = 'ng-car';
  public isShow: any;
  constructor(private router: Router) { }

  ngOnInit() {
    //监听路由的变化  this.router 路由对象
    this.router.events
      .pipe(
        filter(event => event instanceof NavigationEnd),
        map(() => this.router)
      )
      .subscribe((event) => {
        let url = this.router.routerState.snapshot.url;
        if (url == '/' || url == '/mallclass' || url == '/jy-list' || url == '/live_tv' || url == '/my') {
          this.isShow = true;
        } else {
          this.isShow = false;
        }
      });


  }
}
